﻿function environment() {
    this.refreshStyles = function () { 
        $(".button, input:submit, button").button();
        $(".button-icon-plus").button({
                icons: {
                primary: "ui-icon-plus"
            }
        });

        $(".button-icon-return").button({
            icons: {
                primary: "ui-icon-arrowreturn-1-w"
            }
        });

        $(".button-icon-return-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-arrowreturn-1-w"
            }
        });


        $(".button-icon-edit-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-pencil"
            }
        });

        $(".button-icon-close-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-close"
            }
        });

        $(".button-icon-remove-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-trash"
            }
        });

        $(".button-icon-play-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-play"
            }
        });

        $(".button-icon-pause-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-pause"
            }
        });
 
        $(".submit").click(function(){
            //clear placeholder values
            $("input[type='text'], textarea").each(function (){
                if ($(this).hasClass('placeholder'))
                {
                    $(this).val('');
                }
            });
        });

        $('input[placeholder], textarea[placeholder]').placeholder();
        $(".textBoxReadOnly").attr('readonly', true);
        $(".textBoxReadOnly").css("color", "#52697E");

        $(".textCalendar").datepicker({ buttonImage: "/images/calendar-icon-16x16.png",
            buttonImageOnly: true,
            showOn: "both",
            showButtonPanel: true,
            showOtherMonths: true,
            changeMonth: true,
            changeYear: true,
        });
        $(".textCalendar").attr("size", "10");
        $(".textCalendar").attr("maxlength", "10");

        $(".textMoney").maskMoney({
            symbol: 'R$ ', 
            showSymbol: true,
            thousands: '.', 
            decimal: ','
        });

        $(".textMoney").attr("size", "13");
        $(".textMoney").attr("maxlength", "15");

        $(".search").autocomplete({
            minLenght: 2
        });

        $(".search").attr("maxlength", "80");

        $(".validation-summary-errors").addClass("ui-state-error ui-corner-all")
                                        .css("padding", "2px")
                                        .css("margin", "5px 0 5px 0");

        $( "#dialog:ui-dialog" ).dialog( "destroy" );
		$( "#progressbar" ).progressbar({
			value: 100
		});

        $(".searchable-combobox").combobox();
    }
}

var loader = function (){
    this.show = function (){
		        $( "#dialog-modal" ).dialog({
			        height: 70,
			        modal: true,
                    resizable: false,
                    closeOnEscape:false,
                    closeText:'hide',
                    dialogClass: 'no-close'
		        });
    }

    this.hide = function (){
        $( "#dialog-modal" ).dialog('destroy');
    }
}

var environment = new environment();

$(function () { 
    environment.refreshStyles();
    $.datepicker.setDefaults($.datepicker.regional["pt-BR"]);
});